/*
CREATED		12/20/2007
MODIFIED		1/9/2008
PROJECT		
MODEL		
COMPANY		
AUTHOR		
VERSION		
DATABASE		ORACLE 10G 
*/


DROP TABLE "COMMENTS"
/
DROP TABLE "PICTURES"
/
DROP TABLE "CATEGORIES"
/
DROP TABLE "USERS"
/
DROP SEQUENCE "SEQ_COMMENTS"
/
DROP SEQUENCE "SEQ_PICTURES"
/
DROP SEQUENCE "SEQ_CATEGORIES"
/
DROP SEQUENCE "SEQ_USERS"
/

-- CREATE TYPES SECTION


-- CREATE TABLES SECTION


CREATE TABLE "USERS" (
	"USERID" INTEGER NOT NULL ,
	"USERNAME" VARCHAR2 (30),
	"USERPASSWORD" VARCHAR2 (30),
PRIMARY KEY ("USERID") 
) 
/

CREATE TABLE "CATEGORIES" (
	"CATEGORYID" INTEGER NOT NULL ,
	"CATEGORYNAME" VARCHAR2 (30),
	"PARENTID" INTEGER,
	"USERID" INTEGER NOT NULL ,
PRIMARY KEY ("CATEGORYID") 
) 
/

CREATE TABLE "PICTURES" (
	"PICTUREID" INTEGER NOT NULL ,
	"PICTURENAME" VARCHAR2 (200),
	"CATEGORYID" INTEGER NOT NULL ,
PRIMARY KEY ("PICTUREID") 
) 
/

CREATE TABLE "COMMENTS" (
	"COMMENTID" INTEGER NOT NULL ,
	"COMMENTTEXT" VARCHAR2 (2000),
	"PICTUREID" INTEGER NOT NULL ,
PRIMARY KEY ("COMMENTID") 
) 
/


-- CREATE ALTERNATE KEYS SECTION


-- CREATE INDEXES SECTION


-- CREATE FOREIGN KEYS SECTION

ALTER TABLE "CATEGORIES" ADD  FOREIGN KEY ("USERID") REFERENCES "USERS" ("USERID") 
/

ALTER TABLE "PICTURES" ADD  FOREIGN KEY ("CATEGORYID") REFERENCES "CATEGORIES" ("CATEGORYID") 
/

ALTER TABLE "COMMENTS" ADD  FOREIGN KEY ("PICTUREID") REFERENCES "PICTURES" ("PICTUREID") 
/


-- CREATE OBJECT TABLES SECTION


-- CREATE XMLTYPE TABLES SECTION


-- CREATE PROCEDURES SECTION


-- CREATE FUNCTIONS SECTION


-- CREATE VIEWS SECTION


-- CREATE SEQUENCES SECTION

CREATE SEQUENCE "SEQ_COMMENTS"
/
CREATE SEQUENCE "SEQ_PICTURES"
/
CREATE SEQUENCE "SEQ_CATEGORIES"
/
CREATE SEQUENCE "SEQ_USERS"
/

-- CREATE TRIGGERS FROM REFERENTIAL INTEGRITY SECTION


-- CREATE USER TRIGGERS SECTION


-- CREATE PACKAGES SECTION


-- CREATE SYNONYMS SECTION


-- CREATE ROLES SECTION


-- USERS PERMISSIONS TO ROLES SECTION


-- ROLES PERMISSIONS SECTION

/* ROLES PERMISSIONS */


-- USER PERMISSIONS SECTION

/* USERS PERMISSIONS */


-- CREATE TABLE COMMENTS SECTION


-- CREATE ATTRIBUTE COMMENTS SECTION


-- AFTER SECTION


